package com.csap.framework.oauth2.server.login.spi;

import cn.dev33.satoken.oauth2.model.AccessTokenModel;
import com.csap.framework.extension.result.ResultParam;
import com.csap.framework.oauth2.request.PasswordRequest;
import com.csap.framework.oauth2.server.login.Oauth2LoginSpi;
import com.csap.framework.oauth2.server.service.Oauth2ServerService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 账号密码登录
 *
 * @Author ycf
 * @Date 2021/8/9 1:26 下午
 * @Version 1.0
 */
@Component
public class Oauth2LoginSpiUserName implements Oauth2LoginSpi<PasswordRequest, ResultParam<AccessTokenModel>> {
    @Resource
    private Oauth2ServerService oauth2ServerService;

    @Override
    public ResultParam<AccessTokenModel> login(PasswordRequest passwordRequest) {
        return oauth2ServerService.login(passwordRequest.getUserName(), passwordRequest.getPlatform(), passwordRequest.getPassword(), passwordRequest.getDeviceType(), passwordRequest.getClient_id());
    }
}
